
export function asideByUserRole(role) {
    const menuItems = {
        user: [
            { name: "borrow-hall", title: "借阅大厅", icon: "Document" },
            { name: "shopping-car", title: "购物车", icon: "Menu" },
            { name: "self-message", title: "个人信息", icon: "Location" },
            { name: "order-detail", title: "订单详情", icon: "Setting" },
            { name: "contact-admin", title: "联系管理员", icon: "List" },
        ],
        admin: [
            { name: "library-management", title: "图书管理", icon: "Document" },
            { name: "user-management", title: "用户管理", icon: "Menu" },
            { name: "order-management", title: "订单管理", icon: "Location" },
            { name: "view-comments", title: "查看留言", icon: "Setting" },
            { name: "system-setting", title: "系统设置", icon: "List" },
        ],
        // 添加云盘角色菜单
        cloud: [
            { name: "/cloud", title: "云盘首页", icon: "Document" },
            { name: "/cloud/upload", title: "上传文件", icon: "Upload" },
            { name: "/cloud/download", title: "下载文件", icon: "Download" },
        ],
        // 添加云盘管理员菜单
        cloudAdmin: [
            { name: "/admin/dashboard", title: "仪表盘", icon: "DataBoard" },
            { name: "/admin/users", title: "用户管理", icon: "User" },
            { name: "/admin/files", title: "文件管理", icon: "Document" },
            { name: "/cloud", title: "返回前台", icon: "Back" },
        ],
    };
    return menuItems[role] || [];
}
/* ---------------Check检查服务--------------- */
// 文件大小格式化
export function formatFileSize(bytes) {
    if (bytes === 0) return '0 B';
    const k = 1024;
    const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
    const i = Math.floor(Math.log(bytes) / Math.log(k));
    return (bytes / Math.pow(k, i)).toFixed(2) + ' ' + sizes[i];
}

// 检查邮箱
export function CkEmail(data) {
    let reg = /^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(.[a-zA-Z0-9_-]+)+$/;
    return !reg.test(data) ? true : false;
}
// 检查用户名
export function CKUser(data) {
    // 5-15位英文或数字组成
    let reg = /^[a-zA-Z0-9_-]\S{4,14}$/;
    return !reg.test(data) ? true : false;
}
// 检查密码
export function CKPass(data) {
    // 验证密码 6至15位的字母+数字
    let reg = /^[a-zA-Z0-9_-]\S{4,14}$/;
    return !reg.test(data) ? true : false;
}